//
// Created by ych on 2/13/24.
//

#ifndef MATINTERPRETER_YCH_STATE_H
#define MATINTERPRETER_YCH_STATE_H

#include "../common/ych_object.h"
#include "../common/ych_error.h"
#include "../common/system.h"
#include "../compiler/parser.h"
#include "../vm/executor.h"
#include "../vm/memory.h"

#define YSTATE_INTERACTIVE 1
#define YSTATE_INPUT 2
#define YSTATE_COMPILER 3
#define YSTATE_RUNBYTECODE 4
typedef struct YState {
    int mode;
    Reader reader;
    Lexer lexer;
    Parser parser;
    Executor executor;
    VMMemory memory;
    ErrorStack errors;
} YState;

void initYState(YState *y_state,int mode);
void startYState(YState *y_state);
void run2YState(YState *y_state, char *file_path);
void run1YState(YState *y_state,char *buffer);
void rollbackYState(YState *y_state);
void showErrors(YState *y_state);
void freeMemory(YState *y_state);
void destroyYState(YState *y_state);

#endif //MATINTERPRETER_YCH_STATE_H
